﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OrganizerLibrary;
using OrganizerLibrary.Settings;

namespace DownloadOrganizerConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            OrganizerContext ctx = OrganizerContext.Instantiate(OrganizerSettings.Instance.DownloadDirectory);
            using(Organizer organizer = Organizer.Instantiate(ctx))
            {
                Parallel.Invoke(organizer.Start);
                WaitForEscape();
                organizer.Stop();
            }
        }

        private static void WaitForEscape()
        {
            Console.WriteLine("Press ESC to stop organizer...");
            ConsoleKeyInfo cki;
            do
            {
                cki = Console.ReadKey();
            } while (cki.Key != ConsoleKey.Escape);
        }
    }
}
